home *** CD-ROM | disk | FTP | other *** search
/ Info-Mac 3 / Info_Mac_1994-01.iso / Development / Source / MSG Graphic Effects 1.0 Source / Circle bulge.c < prev    next >
Encoding:
C/C++ Source or Header  |  1993-08-23  |  2.1 KB  |  70 lines  |  [TEXT/KAHL]

  1. /*******************************************************************************
  2.  * Copyright © 1992-1993 Mark Pilgrim                                          *
  3.  *                                                                             *
  4.  * This file is provided as is, and may be freely distributed unaltered.  This *
  5.  * message must accompany any copy of this file.  This file may be used or     *
  6.  * modified for use for a non-commercial product provided that appropriate     *
  7.  * credit is given to the author named above.                                  *
  8.  * Commercial use of this source code is prohibited.                           *
  9.  ******************************************************************************/
  10.  
  11. #include "msg misc.h"
  12. #include "msg timing.h"
  13.  
  14. #define    startgap            1
  15. #define    gapratio            6
  16. #define    zeropointH            15
  17. #define CorrectTime 3
  18.  
  19. void CircleBulge(GrafPtr);
  20.  
  21. /* This copies ovals that always run from the left of the screen to the right,
  22.    but start really squashed and get geometrically taller.  */
  23.    
  24. void CircleBulge(GrafPtr sourceGrafPtr)
  25. {
  26.     Rect        theRect;
  27.     Rect        source;
  28.     RgnHandle    curregion;
  29.     Point        zeropoint;
  30.     int            cy=MAIN_WINDOW_HEIGHT/2;
  31.     int            gap=startgap;
  32.     
  33.     source.top=source.left=0;
  34.     source.right=MAIN_WINDOW_WIDTH;
  35.     source.bottom=MAIN_WINDOW_HEIGHT;
  36.  
  37.     theRect=source;
  38.     theRect.top=cy-gap;
  39.     theRect.bottom=cy+gap;
  40.         
  41.     curregion=NewRgn();
  42.     zeropoint.v=0;
  43.     zeropoint.h=zeropointH;       /* when we copy zeropoint, it's time to stop */
  44.     do
  45.     {
  46.         StartTiming();
  47.  
  48.         SetEmptyRgn(curregion);
  49.         OpenRgn();
  50.             FrameOval(&theRect);  /* this makes the region for copying */
  51.         CloseRgn(curregion);
  52.  
  53.         CopyBits(&(sourceGrafPtr->portBits), &(gMainWindow->portBits),
  54.                 &source, &source, 0, curregion);
  55.  
  56.         theRect.top-=gap;
  57.         theRect.bottom+=gap;     /* make the oval taller */
  58.         gap++;
  59.         gap+=gap/gapratio;       /* make the oval grow faster next time */
  60.         
  61.         TimeCorrection(CorrectTime);
  62.     }
  63.     while (!(PtInRgn(zeropoint, curregion)));   /* quit when we hit zeropoint */
  64.  
  65.     CopyBits(&(sourceGrafPtr->portBits), &(gMainWindow->portBits),
  66.             &source, &source, 0, 0L);          /* copy the whole screen to end it */
  67.     
  68.     DisposeRgn(curregion);
  69. }
  70.